package yunquan.wang.base.process;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

import org.jbpm.task.service.TaskServer;
import org.jbpm.task.service.hornetq.HornetQTaskServer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 人工任务服务器端
 * @author wangyunquan
 *
 */
public class ProcessTaskServer {
	protected  Logger logger = LoggerFactory.getLogger(this.getClass());
	
	private org.jbpm.task.service.TaskService jtaskService;
	
	public void setJtaskService(org.jbpm.task.service.TaskService jtaskService) {
		this.jtaskService = jtaskService;
	}
	private TaskServer server = null;
	@PostConstruct
	public void startServer()
	{
		 server = new HornetQTaskServer(jtaskService, 5445);
			try {
				  Thread thread = new Thread(server);  
			        thread.start();
			} catch (Exception e) {
				e.printStackTrace();
			}
		logger.info("------------------流程服务器启动");
	}
	@PreDestroy
	public void stopServer()
	{
		try {
			server.stop();
		} catch (Exception e) {
			e.printStackTrace();
		}
		logger.info("------------------流程服务器关闭");
	}
}
